import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

import hello from '@/store/modules/hello'

export const store = new Vuex.Store({
  state: {
    count: 6,
    user:JSON.parse(window.sessionStorage.getItem("user"))
  },
  mutations: { /* 命令 */
    inc (state) {
      state.count++
    },
    setUser(state,user){
      state.user=user;
    }
  },
  actions:{
    waitInc (context,n) {
      setTimeout(()=>{
        for (var i = 0; i < n; i++) {
          context.commit('inc')
        }
      }, 2000)
    }
  },
  modules:{
    hello:hello
  }
})

